package com.example.asapp.activeMq;

import com.example.asapp.demo.record.Record;
import com.example.asapp.demo.record.RecordDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import java.util.UUID;


@Component
@Slf4j
public class QueueConsumerListener
{
    @Autowired
    RecordDao recordDao;
    //queue模式的消费者
    @JmsListener(destination="${spring.activemq.queue-name}", containerFactory="queueListener")
    public void readActiveQueue(String message) {
        log.info("consumer listened! message is {}",message);
        Record record=new Record();
        record.setIdy(UUID.randomUUID().toString());
        record.setIdy(UUID.randomUUID().toString());
        recordDao.save(record);
    }

    @JmsListener(destination="${spring.activemq.queue-name}", containerFactory="queueListener")
    public void readActiveQueue2(String message) {
        log.info("consumer listened! message is {}",message);
    }
}